#pragma once
#include "../../include/types.h"
#include "../../include/riscv.h"
#include "../proc/spinlock.h"
#include "../proc/proc.h"
#include "sleeplock.h"
#include "fs.h"

struct superblock;
struct buf;
// Contents of the header block, used for both the on-disk header block
// and to keep track in memory of logged block# before commit.
struct logheader {
    int n;
    int block[LOGBLOCKS];
  };
  
  struct log {
    spinlock lock;
    int start;
    int outstanding; // how many FS sys calls are executing.
    int committing;  // in commit(), please wait.
    int dev;
    struct logheader lh;
  };

  void
  initlog(int dev, struct superblock *sb);

  void
  begin_op(void);

  void
  end_op(void);

  void
  log_write(struct buf *b);